Operator Assignment Support#214
Merged
Merged
Conversation
CatarinaGamboa
requested changes
May 11, 2026
Collaborator
CatarinaGamboa
left a comment
There was a problem hiding this comment.
Needs to cover more operations on the RHS, and more examples that fail the refinements.
Also, there are more similar ops that we are not targetting right? like bitwise &=, ..., we don't need but it should be a todo or maybe we should throw an error or something say we dont support them
| if (literal.getValue() == null) | ||
| throw new CustomError("Null literals are not supported", literal.getPosition()); | ||
| return new Predicate(literal.getValue().toString(), element); | ||
| } |
Collaborator
There was a problem hiding this comment.
What if it is another kind of expression? we need more fallbacks.
Counter-example (with your example class):
int t3(@Refinement("_ >= 0") int x) {
@Refinement("_ == 10 || _ == 11")
int y = 10;
y += remainder(x); // x is now >= 6
return x;
}
outputs
Error: class com.microsoft.z3.BoolExpr cannot be cast to class com.microsoft.z3.ArithExpr (com.microsoft.z3.BoolExpr and com.microsoft.z3.ArithExpr are in unnamed module of loader org.codehaus.mojo.exec.URLClassLoaderBuilder$ExecJavaClassLoader @cb7fa71)
| } | ||
|
|
||
| @Override | ||
| public <T, A extends T> void visitCtOperatorAssignment(CtOperatorAssignment<T, A> assignment) { |
| x %= 2; // x is now == 0 || x is now == 1 | ||
| return x; | ||
| } | ||
| } |
Collaborator
There was a problem hiding this comment.
Can we also get some negative cases for examples?
Collaborator
Author
|
You're right. Will fix it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for Java operator assignments such as
+=,-=,*=,/=, and%=in the refinement checking.It works by modeling operator assignments as equivalent simple assignments:
x += y→x = x + y.Example
Before we had an error in the return statement because the
x += 1was ignored. Now we don't.Related Issue
None.
Type of change
Checklist
liquidjava-example/src/main/java/testSuite/(Correct*/Error*)mvn testpasses locally